package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.assemble.AssembleBO;
import com.micro.modual.model.dto.assemble.AssembleDetailDTO;
import com.micro.modual.model.dto.assemble.AssembleListDTO;
import com.micro.modual.service.AssembleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>拼团表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "拼团管理",tags = "拼团管理")
@RestController
@RequestMapping(value = "assemble")
public class AssembleController {

    @Autowired
    private AssembleService assembleService;

    /**
     * <h2>查找拼团表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<AssembleListDTO> {@link AssembleListDTO}s  拼团表 列表返回对象
     */
    @ApiOperation(value = "查询拼团表列表" ,notes = "查询拼团表列表")
    @GetMapping(value = "/findAssembleList")
    public RespJsonPageData<AssembleListDTO> findAssembleList(@RequestParam  Map<String,Object> params){
        return assembleService.findList(params,AssembleListDTO.class);
    }

    /**
     * <h2>根据主键编号查看拼团表详情</h2>
     * @param id  拼团表 主键编号
     * @return {@link AssembleDetailDTO}  拼团表 详情
     */
    @ApiOperation(value = "查询拼团表详情",notes = "根据主键编号，查询拼团表详情")
    @GetMapping(value = "/findAssembleDetail/{id}")
    public RespJsonData<AssembleDetailDTO> findAssembleDetail(@PathVariable("id") Long id){
        return assembleService.findDetail(id,AssembleDetailDTO.class);
    }

    /**
     * <h2>新增拼团表详情</h2>
     * @param assembleBO {@link AssembleBO} 拼团表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增拼团表",notes = "新增拼团表")
    @PostMapping(value = "/addAssemble")
    public RespJson addAssemble(@RequestBody AssembleBO assembleBO){
        return assembleService.addAssemble(assembleBO);
    }

    /**
     * <h2>修改拼团表详情</h2>
     * @param assembleBO  {@link AssembleBO} 拼团表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改拼团表",notes = "修改拼团表")
    @PostMapping(value = "/editAssemble")
    public RespJson editAssemble(@RequestBody AssembleBO assembleBO){
        return assembleService.editAssemble(assembleBO);
    }

    /**
     * <h2>根据主键编号删除拼团表信息</h2>
     * @param id  拼团表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除拼团表",notes = "根据地址ID，删除拼团表")
    @PostMapping(value = "/deleteAssemble/{id}")
    public RespJson deleteAssemble(@PathVariable("id") Long id){
        return assembleService.deleteAssemble(id);
    }
}

